package com.yj.cmp.sdk.fusioncompute.compute.vm;

import com.yj.cmp.sdk.fusioncompute.compute.vm.dto.VmDiskExpansionDto;
import com.yj.cmp.sdk.fusioncompute.compute.vm.dto.VmMountDiskDto;
import com.yj.cmp.sdk.fusioncompute.compute.vm.dto.VmSnapshotsDto;
import com.yj.cmp.sdk.fusioncompute.compute.vm.dto.VmUnmountDiskDto;
import com.yj.cmp.sdk.fusioncompute.compute.vm.vo.VmListVo;
import com.yj.cmp.sdk.fusioncompute.compute.vm.vo.VmSnapshotsDetailVo;
import com.yj.cmp.sdk.fusioncompute.compute.vm.vo.VmSnapshotsListVo;
import com.yj.cmp.sdk.fusioncompute.compute.vm.vo.VmVo;
import com.yj.cmp.sdk.fusioncompute.identity.task.TaskVo;
import okhttp3.ResponseBody;
import org.springframework.stereotype.Service;
import retrofit2.Call;
import retrofit2.http.*;

import java.util.Map;

@Service
public interface FcVmService {

    @GET("vms")
    Call<VmListVo> vmList(@HeaderMap Map<String, Object> headers, @QueryMap Map<String, Object> queryParam);

    @GET("vms/{vmUri}")
    Call<VmVo> vmDetail(@HeaderMap Map<String, Object> headers, @Path("vmUri") String vmUri, @QueryMap Map<String, Object> queryParam);

    @POST("vms")
    Call<TaskVo> creatVm(@HeaderMap Map<String, Object> headers, @Body VmVo vmVo);

    @DELETE("vms/{vmUri}")
    Call<TaskVo> deleteVm(@HeaderMap Map<String, Object> headers, @Path("vmUri") String vmUri, @QueryMap Map<String, Object> queryParam);

    @POST("vms/{vmUri}/action/start")
    Call<TaskVo> startVm(@HeaderMap Map<String, Object> headers, @Path("vmUri") String vmUri);

    @POST("vms/{vmUri}/action/stop")
    Call<TaskVo> stopVm(@HeaderMap Map<String, Object> headers, @Path("vmUri") String vmUri, @QueryMap Map<String, Object> queryParam);

    @POST("vms/{vmUri}/action/reboot")
    Call<TaskVo> rebootVm(@HeaderMap Map<String, Object> headers, @Path("vmUri") String vmUri, @QueryMap Map<String, Object> queryParam);

    @GET("vms/{vmId}/snapshots")
    Call<VmSnapshotsListVo> getVmSnapshotsList(@HeaderMap Map<String, Object> headers, @Path("vmId") String vmId);

    @POST("vms/{vmId}/snapshots")
    Call<TaskVo> createVmSnapshot(@HeaderMap Map<String, Object> headers, @Path("vmId") String vmId, @Body VmSnapshotsDto vmSnapshotsDto);

    @GET("vms/{vmId}/snapshots/{vmSnapshotId}?refreshflag=false")
    Call<VmSnapshotsDetailVo> getVmSnapshotsDetail(@HeaderMap Map<String, Object> headers, @Path("vmId") String vmId, @Path("vmSnapshotId") String vmSnapshotId);

    @DELETE("vms/{vmId}/snapshots/{vmSnapshotId}")
    Call<TaskVo> deleteVmSnapshot(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Path("vmSnapshotId") String vmSnapshotId);

    @POST("vms/{vmId}/snapshots/{vmSnapshotId}/action/resumevm")
    Call<TaskVo> restoreVmBySnapshot(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Path("vmSnapshotId") String vmSnapshotId);

    @PUT("vms/{vmId}/snapshots/{vmSnapshotId}")
    Call<ResponseBody> updateVmSnapshot(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Path("vmSnapshotId") String vmSnapshotId, @Body VmSnapshotsDto vmSnapshotsDto);

    @GET("vms/{vmId}/getvss")
    Call<Map<String, Object>> getVmVssStatus(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId);

    @POST("vms/{vmId}/action/attachvol")
    Call<TaskVo> mountVmDisk(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Body VmMountDiskDto vmMountDiskDto);

    @POST("vms/{vmId}/action/detachvol")
    Call<TaskVo> unmountVmDisk(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Body VmUnmountDiskDto vmUnmountDiskDto);

    @POST("vms/{vmId}/action/expandvol")
    Call<TaskVo> expandVmDisk(@HeaderMap Map<String, Object> headerMap, @Path("vmId") String vmId, @Body VmDiskExpansionDto vmDiskExpansionDto);
}
